#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#undef DEBUG
#undef RDEBUG
#undef MEDIAN
int *array;
int loc;
int maxLength;
char *buf;

void display();
float median(){
	#ifdef MEDIAN
		printf("%d",loc);
	#endif
	if(loc==0)return -1;
	int *ptr=array;
	if(loc%2!=0){
		if(loc==1)return ptr[loc-1];
		else
		return ptr[loc/2];
	}
	else{
		float temp=(float)(ptr[(loc)/2]+ptr[(loc-2)/2]);
		return temp/2;
	}
}


int noOperations(){
	char c;
	int operations=0;
	scanf("%d",&operations);
	return operations;
}

void init(){
	int i=0;
	int *ptr=array;
	for(i=0;i<maxLength;i++){
		*ptr=0;	
		ptr++;
	}
}
void add(int num){

#ifdef DEBUG
	printf("add ->%d\n",num);
#endif
	int i =0;
	int *local=array;
	while(*local!=0){
		if(*local>num){
#ifdef DEBUG
	printf("%d\t%d\n",*local,num);
#endif
			break;
		}

		local++;
#ifdef DEBUG
	printf("hi1\n");
#endif
	}

	while(*local!=0){
		int temp=*local;
		*local=num;
		num=temp;
		local++;
	#ifdef DEBUG
		printf("hi%d\n",*local);
	#endif
	}

	
	*local=num;
}
int removeNum(int n){
	int i=0;
	int *ptr=array;
	while(ptr[i]!=n&&i<maxLength){
		if(ptr[i]==n)break;
		else
			i++;
	}
	if(i<maxLength){
		int j=maxLength-2;
		int temp=ptr[j+1];
		
		while(j>=i){
			ptr[j]+=temp;	
			temp=ptr[j]-temp;
			ptr[j]=ptr[j]-temp;	
			j--;
		}

	}
	else{
			printf("Wrong!\n");
	//			strcat(buf,"Wrong!\n");
		return -1;
	}
	return 1;
}
void clearBuffer(){
	char c;
	while((c=fgetc(stdin))!='\n');
}

void start(){
	int i=0;
	char c;
	clearBuffer();
	for(i=0;i<maxLength;i++){
			char* abc=(char*)malloc(100);
			char *ptr=abc;
			int number=0;
			gets(ptr);

			char operation=abc[0];
			ptr=abc;
			ptr++;
			ptr++;

			while(*ptr!='\0'){

				number=number*10+(*ptr-48);
				ptr++;

			}

			if(operation=='a'){
				add(number);
				loc++;

				#ifdef DEBUG
				printf("after adding\n");
				display();
				printf("\n");
				#endif
				char ch[10];
				float temp=median();
				if(temp!=-1)
					sprintf(ch,"%g",temp);
				else
					sprintf(ch,"Wrong!");
				
					printf("%s\n",ch);
//				strcat(buf,ch);
	//			strcat(buf,"\n");
		//		printf("%d\n",median());

				}
			if(operation=='r'){
				if(removeNum(number)==1){
					loc--;
					char ch[10];
					float temp=median();
					if(temp!=-1)
						sprintf(ch,"%g",temp);
					else
						sprintf(ch,"Wrong!");
					printf("%s\n",ch);		
//					strcat(buf,ch);
//					strcat(buf,"\n");
//					printf("%d\n",median());
					#ifdef RDEBUG
			
					printf("remove");
					display();
				#endif

				}

						}
			
			
		}
	}
void initA(){
	int i=0;
	for(i=0;i<maxLength;i++){
		array[i]=0;
	}
}
void display(){
	int *local=array;
	int i=0;
	for(i=0;i<maxLength;i++){
		printf("%d\n",*local);
		local++;
	}
}
void simpleArray(int n){
	int *ptr=array;
	while(*ptr!=0){
		ptr++;
	}
	*ptr=n;

}

int main(){

	loc=0;;
	maxLength=noOperations();
	array=(int*)malloc(maxLength*sizeof(int));
	buf=(char*)malloc(maxLength*sizeof(char));
	initA();
	start();
//	display();
//	printf("%s",buf);
}

